<?php
require_once './config/sys_config.php';
require_once MB_CONF_DIR  . '/user_config.php';
require_once MB_COMM_DIR  . '/token.class.php';

echo "====================>> ENCODE Start <<====================<br>";
$member['uid'] = 1;
$member['username']  ="lvfeng";
$member['password'] = md5(MBToken::_generate_key());

$authcode = MBToken::authcode($member[uid]."\t".$member[username]."\t".$member[password], 'ENCODE');
setcookie(MB_COOKIE_PREFIX.'token_test', $authcode, time()+MB_TOKEN_COOKIE_EXPIRE);
echo $authcode."<br>";
echo "====================>> ENCODE End <<====================<br>";

echo "====================>> DECODE Start <<====================<br>";
$authcode = $_COOKIE[MB_COOKIE_PREFIX.'token_test'];
echo $authcode."<br>";
$token_str = MBToken::authcode($authcode);
$token_arr = explode("\t", $token_str);
var_dump($token_arr);

$mb_token = new MBToken();
if($row = $mb_token->select_token_by_name_and_sign($token_arr[1], $token_arr[2])){
	var_dump($row);
}
echo "====================>> DECODE End <<====================<br>";
?>